<extend name="./Public/base"/>
<block name="title"><title>用户管理</title></block>
<block name="css">
    <!--datatable-->
    <link rel="stylesheet" href="__PUBLIC__/Admin/css/dataTables.bootstrap.min.css">
</block>

<block name="content">
    <!-- Content Wrapper. Contains page content -->
    <div class="content-wrapper">
        <include file="Partials:errors"/>
        <include file="Partials:success"/>
        <!-- Main content -->
        <section class="content">
            <div class="row">
                <div class="col-xs-12">
                    <div class="box">
                        <div class="box-header">
                            <a href="{:U('Admin/user/create')}" type="button" class="btn-flat pull-right">
                                <button type="button" class="btn btn-block btn-success fa fa-plus-circle">添加用户</button>
                            </a>
                        </div>
                        <!-- /.box-header -->
                        <div class="box-body">
                            <table id="example1" class="table table-bordered table-striped table-hover">
                                <thead>
                                <tr class="active">
                                    <th>ID</th>
                                    <th>头像</th>
                                    <th>用户名</th>
                                    <th>用户组</th>
                                    <th>添加时间</th>
                                    <th>更新时间</th>
                                    <th>操作</th>
                                </tr>
                                </thead>
                                <tbody>
                                <volist name="user" id="user">
                                    <tr class="active">
                                        <td style="line-height: 50px">{$user.id}</td>
                                        <td>
                                            <img class="img-circle img-bordered-sm" src="__ROOT__/Uploads{$user.image|setImage=###}" width="50px" height="50px" alt="User Image">
                                        </td>
                                        <td style="line-height: 50px">{$user.name}</td>
                                        <td style="line-height: 50px"><if condition="$user.id eq 1">超级管理员</if>{$user.role_id}</td>
                                        <td style="line-height: 50px"><if condition="$user.created_time neq null">{$user.created_time|date='Y-m-d H:i:s',###}</if></td>
                                        <td style="line-height: 50px"><if condition="$user.updated_time neq null">{$user.updated_time|date='Y-m-d H:i:s',###}</if></td>
                                        <td style="line-height: 50px">
                                            <a style="margin:3px;" href="{:U('Admin/user/edit')}?id={$user.id}" class="X-Small btn-xs text-success "><i class="fa fa-edit"></i> 编辑</a>
                                            <a style="margin:3px;" href="#" attr="{$user.id}" class="delBtn X-Small btn-xs text-danger"><i class="fa fa-times-circle"></i> 删除</a>
                                        </td>
                                    </tr>
                                </volist>
                                </tfoot>

                            </table>
                            <div style="position:relative;left:80%">

                            </div>
                        </div>
                        <!-- /.box-body -->
                    </div>
                    <!-- /.box -->
                </div>
                <!-- /.col -->
            </div>
            <!-- /.row -->
        </section>
        <!-- /.content -->
    </div>
    <!-- /.content-wrapper -->
    <!-- /.content -->
    <div class="modal fade" id="modal-delete" tabIndex="-1">
        <div class="modal-dialog modal-warning">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal">
                        ×
                    </button>
                    <h4 class="modal-title">提示</h4>
                </div>
                <div class="modal-body">
                    <p class="lead">
                        <i class="fa fa-question-circle fa-lg"></i>
                        确认要删除这个用户吗?
                    </p>
                </div>
                <div class="modal-footer">
                    <form class="deleteForm" method="POST" action="">
                        <input type="hidden" name="id" value="">
                        <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
                        <button type="submit" class="btn btn-danger">
                            <i class="fa fa-times-circle"></i> 确认
                        </button>
                    </form>
                </div>


            </div>
        </div>
    </div>
</block>

<block name="js">
    <!-- DataTables -->
    <script src="__PUBLIC__/Admin/js/jquery.dataTables.min.js"></script>
    <script src="__PUBLIC__/Admin/js/dataTables.bootstrap.min.js"></script>
    <!-- page script -->
    <script>
        $(function () {
            $('#example1').DataTable({
                'paging'      : true,
                'lengthChange': true,
                'searching'   : true,
                'ordering'    : true,
                'info'        : true,
                'autoWidth'   : true
            });
            $("table").delegate('.delBtn', 'click', function () {
                var id = $(this).attr('attr');
                $("input[name='id']").val(id);
                $('.deleteForm').attr('action', '/admin/user/delete');
                $("#modal-delete").modal();
            });
        })
    </script>

</block>

